<script>
export default {
  name: "HomePage",
  data() {
    return {
      user:{}
    }
  },
  mounted() {
    try {
      this.user = JSON.parse(localStorage.getItem('user'))
      if (!this.user) {
        this.$router.replace('/login')
      }
    }catch (e) {
      this.$router.replace('/login')
    }
  }
}
</script>

<template>
  <el-container>
    <el-aside width="280px" style="height: 100vh;">
      <el-menu router style="height: 100vh;" class="el-menu-vertical-demo" background-color="#545c64" text-color="#fff" active-text-color="#ffd04b">
        <el-submenu index="1" v-if="user.role == '管理员'">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span>物资管理</span>
          </template>
          <el-menu-item index="/material/save">添加物资</el-menu-item>
          <el-menu-item index="/material/page">物资查询</el-menu-item>
        </el-submenu>
        <el-submenu index="2" v-if="user.role == '管理员'">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span>供应商管理</span>
          </template>
          <el-menu-item index="/provider/save">添加供应商</el-menu-item>
          <el-menu-item index="/provider/page">供应商查询</el-menu-item>
        </el-submenu>
      </el-menu>
    </el-aside>
    <el-main style="height: 100vh;">
      <router-view/>
    </el-main>
  </el-container>
</template>

<style scoped>

</style>
